<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var integerBreak = function (n) {
        let dp = new Array(n + 1).fill(0)
        dp[2] = 1
        for (let i = 3; i <= n; i++) {
          for (let j = 1; j < i; j++) {
            //这里多个dp[i]，是为了同一个i的情况下，取最大值
            dp[i] = Math.max(j * (i - j), j * dp[i - j], dp[i])
          }
        }
        return dp[n]
      }
      integerBreak(10)
    </script>
  </body>
</html>
